/***
This do-file retreives numbers we use in the paper. 
***/

*-------------------------------------------------------------------------------
* Set up 
*-------------------------------------------------------------------------------

* Set $root 
project figstabs, root
if (r(buildrunning)==0) include "${root}/code/config_interactive.do"

* Set globals
project, uses("${root}/code/set_globals.do")
include "${root}/code/set_globals.do"
local category "Employment" 

* Create required subfolders
cap mkdir "${root}/results/Employment"
cap mkdir "${root}/results/paper numbers"
cap mkdir "${root}/results/paper numbers/`category'"

*------------------------------------------------------------------------------- 
*-------------------------------------------------------------------------------

* Import UI Claims data
project, uses("${root}/data/web/data/UI Claims - County - Weekly.csv")
import delimited "${root}/data/web/data/UI Claims - County - Weekly.csv", clear

gen date = mdy(month, day_endofweek, year)

gegen april_ui = sum(initclaims_rate_regular) if inrange(date, mdy(3, 14, 2020), mdy(5, 2, 2020)), by(countyfips)

sum april_ui if countyfips == 6085
local march_may_ui_sc = `=round(`r(mean)', 1)'
di `march_may_ui_sc'

sum april_ui if countyfips == 6019
local march_may_ui_fresno = `=round(`r(mean)', 1)'
di `march_may_ui_fresno'

* Export output numbers to csv file
cap erase "${root}/results/paper numbers/`category'/UI Claims for selected counties in CA.yaml"

yamlout using "${root}/results/paper numbers/`category'/UI Claims for selected counties in CA.yaml", ///
	key("ui_santaclara") ///
	comment("UI Claims Santa Clara") ///
	value(`march_may_ui_sc') 

yamlout using "${root}/results/paper numbers/`category'/UI Claims for selected counties in CA.yaml", ///
	key("ui_fresno") ///
	comment("UI Claims Fresno") ///
	value(`march_may_ui_fresno') 

project, creates("${root}/results/paper numbers/`category'/UI Claims for selected counties in CA.yaml")